package net.cloudcodex.client.campaign.view.panel;

import java.util.Date;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;

public class NotificationListPanel extends FlowPanel {

	private final Label noMsgLabel = new Label();
	private final Label titleMsg = new Label();
	private int notifCount = 0 ;
	


	private final ListBox listBox = new ListBox();
//	private String name;
	
	public NotificationListPanel (String noMessage,String messageTitle) {
		noMsgLabel.setText(noMessage);
		titleMsg.setText(messageTitle);
		this.setStyleName("notificationsPanel");
		titleMsg.setStyleName("titlePanel");
		this.add(titleMsg);
		listBox.setWidth("100%");
		listBox.setVisibleItemCount(4);
		this.add(listBox);
		listBox.addItem(noMsgLabel.getText());
	}

	public void addNotification(String message, Date notifDate) {
		if (notifCount<1){
			listBox.clear();
		}
		String itemAdded = "[" + notifDate + "]" + " - " + message ; 
		listBox.addItem(itemAdded);
		notifCount++;
	}
	
	public void refresh() {
	}
	
	
	
	public void removeNotification(Integer index){
		listBox.removeItem(index);
		notifCount--;
		if (notifCount<1){
			listBox.addItem(noMsgLabel.getText());
		}
	}
	
	public HasClickHandlers getNotificationListBox(){
		return listBox;
	}
	public void addCampaignName(String name) {
//		this.name = name ;
		
	}
}
